package com.lanchetech.user.controller;

import com.lanchetech.bean.request.UserAmtLogReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.UserAmtLogVo;
import com.lanchetech.entity.User;
import com.lanchetech.user.service.UserAmtLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Api(value = "消费流水记录", tags = "消费流水记录")
@RequestMapping("/api/user/amt")
@RestController
public class MiniUserAmtLogController {

    @Autowired
    private UserAmtLogService userAmtLogService;


    @PostMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "当前页", defaultValue = "1", paramType = "Integer", dataType = "body"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", defaultValue = "10", paramType = "Integer", dataType = "body"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "Date", dataType = "body"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "Date", dataType = "body"),
            @ApiImplicitParam(name = "type", value = "类型(1:收入 2:支出)", paramType = "String", dataType = "body")
    })
    @ApiOperation("消费金详情")
    public ResultData<BasePageResp<UserAmtLogVo>> getUserAmtLog(@AuthenticationPrincipal User user,
                                                                @RequestBody UserAmtLogReq req) {
        req.setUserId(user.getId());
        return userAmtLogService.getUserAmtLog(req);
    }
}
